Skip to content

json patch output in tests still string#1630

Open
suarezrominajulieta wants to merge 3 commits into
masterfrom
feature/jsonpatch_noDtoOutputTest
Open

json patch output in tests still string#1630
suarezrominajulieta wants to merge 3 commits into
masterfrom
feature/jsonpatch_noDtoOutputTest

Conversation

@suarezrominajulieta

@suarezrominajulieta suarezrominajulieta commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

In base to Andrea's comment:

"fine for now. not in this PR, but make new branch PR in which you create the following E2E for an API that:

has a POST to create a resource
has a PATCH to manipulate such created resource (404 if no resource)
and then make sure using DTO (there is a EMConfig for it), so that, in same generates test, we have a DTO used for POST following a call on PATCH without DTO (ie Patch must use a string representation, at least for now). any case, test should not fail to compile"

i created this pr with a test that proves that. this is one of the success test generated:

/**
* Calls:
* 1 - (201) POST:/api/jsonpatchdto/resources
* 2 - (200) PATCH:/api/jsonpatchdto/resources/{id}
*/
@Test @Timeout(60)
public void test_4_patchOnResourcReturns200() throws Exception {
    
    BBJsonPatchResourceDto dto_BBJsonPatchResourceDto_1 = new BBJsonPatchResourceDto();
    dto_BBJsonPatchResourceDto_1.setName("1GmNB");
    dto_BBJsonPatchResourceDto_1.setAge(618);
    
    ValidatableResponse res_0 = given().accept("application/json")
            .contentType("application/json")
            .body(dto_BBJsonPatchResourceDto_1)
            .post(baseUrlOfSut + "/api/jsonpatchdto/resources")
            .then()
            .statusCode(201)
            .assertThat()
            .contentType("application/json");
    String location_resources__2 = "/api/jsonpatchdto/resources" + "/" + res_0.extract().body().path("id").toString();
    
    given().accept("text/plain")
            .contentType("application/json-patch+json")
            .body(" [ { " + 
                " \"op\" : \"test\", " + 
                " \"path\" : \"/c\", " + 
                " \"value\" : \"eDgXhicy5FjjbV7h\" " + 
                " }, { " + 
                " \"op\" : \"copy\", " + 
                " \"from\" : \"/b\", " + 
                " \"path\" : \"/a\" " + 
                " }, { " + 
                " \"op\" : \"replace\", " + 
                " \"path\" : \"/d\", " + 
                " \"value\" : -1207061644 " + 
                " } ] ")
            .patch(resolveLocation(location_resources__2, baseUrlOfSut + "/api/jsonpatchdto/resources/-2191309024963475557"))
            .then()
            .statusCode(200)
            .assertThat()
            .contentType("text/plain")
            .body(containsString("patched"));
}

@suarezrominajulieta suarezrominajulieta marked this pull request as ready for review July 7, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant